package com.ea.common.parent.model;



import java.util.Date;


import com.ea.common.utils.IdGen;
import com.ea.common.utils.ToolUtil;
import com.ea.modular.model.sys.ShiroUser;
import com.ea.modular.utils.sys.UserUtil;




public abstract class DataModel<T> extends BaseModel<T> {

	private static final long serialVersionUID = 1L;

	protected String remarks;//备注
	protected ShiroUser createBy;//创建者
	protected Date createDate;//创建时间
	protected ShiroUser updateBy;//更新者
	protected Date updateDate;//更新时间
	protected String delFlag;//删除标识(0:正常,1:删除)
	public DataModel() {
		super();
		this.delFlag=DEL_FLAG_NORMAL;
	}
	public DataModel(String id) {
		super(id);
	}
	/**
	 * 插入之前执行的方法，需要手动调用
	 */
	@Override
	public void preInsert() {
		//自定义ID
		
		if(!this.isNewRecord()){
			setId(IdGen.uuid());
		}
		//获取系统缓存里的User
		ShiroUser shirouser = UserUtil.getCurrentUser();


		if(ToolUtil.isNotEmpty(shirouser)&&ToolUtil.isNotEmpty(shirouser.getId())){
			this.updateBy=shirouser;
			this.createBy=shirouser;
		}
		this.updateDate=new Date();
		this.createDate=this.updateDate;

	}
	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		//获取系统缓存里的User
		ShiroUser shiroUser = UserUtil.getCurrentUser();

		if(ToolUtil.isNotEmpty(shiroUser.getId())){
			this.updateBy=shiroUser;
		}
        this.updateDate=new Date();
		
	}
	public String getRemarks() {
		return remarks;
	}
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	public ShiroUser getCreateBy() {
		return createBy;
	}
	public void setCreateBy(ShiroUser createBy) {
		this.createBy = createBy;
	}
	
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public ShiroUser getUpdateBy() {
		return updateBy;
	}
	public void setUpdateBy(ShiroUser updateBy) {
		this.updateBy = updateBy;
	}
	public Date getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	public String getDelFlag() {
		return delFlag;
	}
	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}



}
